import 'dart:math';

import 'package:flutter/material.dart';
// import 'package:flutter_screenutil/flutter_screenutil.dart';
// import 'package:hockey/services/jzx_config.dart';
// import 'package:hockey/support_files/assets.gen.dart';

import 'jzx_network_image_view.dart';

class JzxUserFrame extends StatelessWidget {
  const JzxUserFrame(
    this.avatar,
    this.size, {
    super.key,
    this.isUpgrade = false,
    this.level = 1,
  });

  final String avatar;

  /// 框的大小，头像用比例计算
  final double size;

  final bool isUpgrade;

  final int level;

  @override
  Widget build(BuildContext context) {
    final levelTemp = min(max(1, level), 5);

    return SizedBox(
      width: size,
      height: size,
      child: Stack(
        alignment: Alignment.center,
        clipBehavior: Clip.none,
        children: [
          JzxNetworkAssets(avatar, width: 11 / 14 * size, radius: 100),
          // Assets.images.icFrame4.image(width: size),
          Positioned(
            top: isUpgrade ? -0.1 * size : 0,
            child: Transform.scale(
              scale: isUpgrade ? 1.68 : 1,
              child: Image.asset(
                'assets/images/ic_frame${isUpgrade ? '_upgrade' : ''}$levelTemp.png',
                width: size,
              ),
            ),
          ),
        ],
      ),
    );
  }
}
